package com.panyunting.notepad.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class UserOpenHelper extends SQLiteOpenHelper {
    public UserOpenHelper(@Nullable Context context) {
        super(context, "MyNotePad.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table note(\n" +
                "   id integer primary key autoincrement,   \n" +
                "   content text,\n" +
                "   notetime text\n" +
                ");";
        db.execSQL(sql);
        //在这里我们继续插入几条数据
        //插入第一条数据
        sql = "insert into note(content,notetime) values('我要休息啦','1990-5-2');";
        db.execSQL(sql);
        //插入第二条数据
        sql = "insert into note(content,notetime) values('我要学习啦','2020-5-2');";
        db.execSQL(sql);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
